import { createRouter, createWebHashHistory } from 'vue-router'


const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/home',
      component: () => import('@/views/Home.vue')
    },
    {
      path: '/',
      redirect: '/home'
    },
    //登录
    {
      path: '/login',
      component: () => import('@/views/Login.vue')
    },
    // 个人信息
    {
      path: '/grxx',
      component: () => import('@/views/grxx.vue')
    },
    
    //注册
    {
      path:'/reg',
      component:()=> import('@/views/Reg.vue')
    },
    //订单信息
    {
      path:'/goods',
      component:() => import('@/views/Goods.vue')
    },
    //购物车
    {
      path:'/cart',
      component:()=>import('@/views/Cart.vue')
    },
    //订单结算
    {
      path:'/cal',
      component:()=>import('@/views/Cal.vue')
    },
    //后台首页
    {
      path:'/admin',
      component:()=>import('@/views/admin/AdminHome.vue'),
      children:[
        {
          path:'goods',
          component:()=>import('@/views/admin/GoodsManage.vue')
        },
        {
          path:'user',
          component:()=>import('@/views/admin/UserManage.vue')
        },
        {
          path:'order',
          component:()=>import('@/views/admin/AdminLogin.vue')
        }
      ]
    },
        //商品详情
        {
          path: '/goodsdetail',
          component: ()=>import('@/views/GoodsDetail.vue'),
          children: [
            //商品介绍
            {
              path: 'goodsintro',  //  /goodsdetail/goodsintro
              component: ()=>import('@/components/goodsdetail/GoodsIntro.vue')
            },
            //商品评价
            {
              path: 'goodsreview',  //  /goodsdetail/goodsreview
              component: ()=>import('@/components/goodsdetail/GoodsReview.vue')
            }
          ]
        },

  ]
})

export default router
